require.config(require_config);

define([
    'jquery',
    'common',
    'ready',
    'template',
    'collection',
    'model',
    'dialog',
    'calendar',
], function ($, common, ready, template, Collection, Model, dialog, calendar) {

    var index = function () {
        this.init();
    };
    index.prototype = {
        init: function () {
            this.event();
            this.fetch();
        },
        fetch: function () {

        },
        event: function () {
            var _this = this;
            $('.form_datetime').calendar();
            $.ajax({
                url: _global.url.api + 'data_management_report',
                type: 'get',
                success: function (res) {
                    var data = res.data;
                    console.log(res.data);
                    //console.log(template('data-item', res.data));
                    $('#date-table').html(template('data-item', res.data))
                }
            });

            //按时间查询
            $('#btn-search').on('click', function (e) {
                e.preventDefault();
                var date =$('input[name="date"]').val();
                $.ajax({
                    url: _global.url.api + 'data_management_report',
                    type: 'get',
                    data:{date:date},
                    success: function (res) {
                        var data = res.data;
                        console.log(res.data);
                        console.log(template('data-item', res.data));
                        $('#date-table').html(template('data-item', res.data))
                        $('#date').html(date);
                    }
                });
            });
        }
    };
    new index();

});